package com.example.homeworkmutualevaluation.Service;

import com.example.homeworkmutualevaluation.Dao.HomeworkDao;
import com.example.homeworkmutualevaluation.Entity.Homework;
import com.example.homeworkmutualevaluation.DTO.UndoHomework;
import jakarta.annotation.Resource;
import org.springframework.stereotype.Service;

import java.sql.Timestamp;
import java.util.List;

@Service
public class HomeworkService {
    @Resource
    private HomeworkDao homeworkDao;
    public int insert(String cno, String title, String content, Timestamp deadline, Timestamp scoretime) {
        Homework homework = new Homework(cno, title, content, deadline, scoretime);
        homeworkDao.save(homework);
        return homework.getId();
    }
    public List<Homework> findAllByCno(String cno) {
        return homeworkDao.findAllByCno(cno);
    }
    public Homework findById(int id) {
        return homeworkDao.findById(id);
    }
    public void save(Homework homework) {
        homeworkDao.save(homework);
    }
    public List<UndoHomework> findAllUndo(String sphone) {
        return homeworkDao.findAllUndo(sphone);
    }
}
